﻿namespace Sidvall.LogManager.Data.ConfigModel.EntityManagers
{
	public partial class ServerConnectionManager<TEntity, TList>
	{
		#region Public Members

		#region InitializeNewValues

		public void InitializeNewValues(IServerConnection value, Sidvall.LogManager.Data.ConnectionType connectionType)
		{
			if (value == null)
				return;
			value.ConnectionTypeId = connectionType;
			value.Name = "** New Server **";
			value.IsEnabled = true;
		}

		#endregion
		#region IsValid

		public bool IsValid(IServerConnection value)
		{
			if (value == null)
				return false;
			switch (value.ConnectionTypeId)
			{
				case ConnectionType.RemoteAccess:
					if (string.IsNullOrWhiteSpace(value.RemoteAddress))
						return false;
					return true;
				default:
					if (string.IsNullOrWhiteSpace(value.ConnectionString))
						return false;
					return true;
			}
		}

		#endregion

		#endregion
	}
}